// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import axios from 'axios'

Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
    el: '#app',
    router,
    components: { App },
    template: '<App/>'
})


//================================使用全局配置在进行网络请求
// axios.defaults.baseURL = 'http://rest.apizza.net/mock/bd03586808d559f9ba6d865f27030be4/',
//     axios.defaults.timeout = 5000

// axios({
//     url: '/home/data',
//     //专门针对get请求的参数拼接
//     params: {
//         type: 'pop',
//         page: 1
//     }
// }).then(res => {
//     console.log(res);
// })


// //axios发送并发请求
// axios.all([axios({
//     url: '/home/data',
// }), axios({
//     url: '/home/data',
// })]).then(result => {
//     console.log("axios发送并发请求：：：" + result);
//     console.log(result);
// })

//==================================创建对应的axios实例
// const instance1 = axios.create({
//     baseURL: 'http://rest.apizza.net/mock/bd03586808d559f9ba6d865f27030be4/',
//     timeout: 5000
// })

// instance1({
//     url: '/home/data',
// }).then(res => {
//     console.log(res);
// })

// const instance2 = axios.create({
//     baseURL: '服务器2',
//     timeout: 5000
// })



//=================================封装一个request模块
//1、导入request模块给
import { request1 } from "./network/request.js"

// request1({
//     url: '/home/data'
// }, res => {
//     console.log("请求成功");
//     console.log(res);
// }, err => {
//     console.log("请求失败");
//     console.log(err);
// })

// request1({
//     baseConfig: {
//         url: '/home/data'
//     },
//     success: function(res) {
//         console.log(res);
//         console.log('请求成功');
//     },
//     failure(err) {
//         console.log('请求失败');
//     }
// })


//========================================最终方案
request1({
    url: '/home/data',
}).then(res => {
    console.log('请求成功');
    console.log(res);
}).catch(err => {
    console.log('请求失败');
    console.log(err);
})